package com.ton;

import com.ton.common.entity.TonPayOrder;
import com.ton.utils.http.RestTemplateUtils;
import com.ton.utils.tron.http.TonscanAPI;
import org.junit.Test;
import org.springframework.boot.test.context.SpringBootTest;

import java.util.Date;
import java.util.HashMap;

@SpringBootTest
public class Http {

    @Test
    public void doPost() {
        TonPayOrder tonPayOrder = new TonPayOrder();
        tonPayOrder.setCallbackUrl("http://47.97.123.219:8020/charge/v1/notify/tronPay");
        tonPayOrder.setAmount(2L);
        tonPayOrder.setCoinType(1);
        tonPayOrder.setAppName("21212");
        tonPayOrder.setAppName("21212");
        if (tonPayOrder.getCallbackUrl().contains("http")) {
            HashMap<String, Object> params = new HashMap<>();
            params.put("orderId", tonPayOrder.getId()); //商户订单号
            params.put("amount", tonPayOrder.getAmount()); //支付金额
            params.put("appId", tonPayOrder.getAppId()); //appid
            params.put("bankMsg", "");
            params.put("time", new Date().getTime());
            params.put("sign", "");
            params.put("status", 2);
            String doPost = RestTemplateUtils.doPost(tonPayOrder.getCallbackUrl(), new HashMap<>(), params);
            System.out.println(doPost);
        }
    }
    @Test
    public void doGet() {
        String transaction = TonscanAPI.getEvents("UQAxp7JMc1uNTO8mLdnmwzCLmqIRUTZhNvDsKHJIUedg_zaa");
        System.out.println(transaction);
        System.out.println(transaction.indexOf("1790576690058104832"));
    }

}
